package Day07.Demo05;



import java.util.ArrayList;
import java.util.Random;

/**
 * @author HYHwtx
 * @version 1.0
 * @date 2022/2/7 18:44
 */
public class Demo04ArrayListReturn {
    public static void main(String[] args) {
        ArrayList<Integer> biglist = new ArrayList<>();
        Random r = new Random();
        for (int i = 0; i <20 ; i++) {
            int num = r.nextInt(100)+1;
            biglist.add(num);
        }
        ArrayList<Integer> smallList = getSmallList(biglist);
        System.out.println("偶数共有："+smallList.size());
        for (int i = 0; i < smallList.size(); i++) {
            System.out.println(smallList.get(i));
        }
    }
    public  static ArrayList<Integer> getSmallList(ArrayList<Integer>biglist){
        //创建一个小集合
        ArrayList<Integer>  smallList = new ArrayList<>();
        for (int i = 0; i < biglist.size(); i++) {
          int num = biglist.get(i);
          if (num%2==0){
              smallList.add(num);
          }
        }
        return smallList;
    }
}
